{extend name="public/layer/main" /}
{block name="css"}{/block}
{block name="style"}{/block}
{block name="js"}{/block}
{block name="script"}
<script type="text/javascript">
    $(function () {
        $("[name=change_status]").select2({
            minimumResultsForSearch: -1, //关闭select框的搜索框
        });
    });

    //审核通过
    function changeStatus(obj, id)
    {
        var status = $(obj).val();
        var data = {
            'status' : status,
            'id' : id,
        };
        $.get("{:url('changeStatus')}", data, function(result){
            if (result.status){
                $(obj).parent().parent().hide('2000');
            }
            layer.msg(result.info,{
                shift: result.status ? 2 : 6
            });
        });
    }
</script>
{/block}
{block name="module"}{$globals.module}{/block}
{block name="controller"}{$globals.controller}{/block}
{block name="action"}{$globals.action}{/block}
{block name="desc"}{$globals.desc}{/block}
{block name="content"}
<div class="box box-primary">
	<div class="box-header with-border">
		<h3 class="box-title">搜索：</h3>
	</div>
	<form class="form-horizontal" action="{:url('page')}" method="get">
	<div class="box-body">
		<div class="form-group">
			{if $request.type == 1}
			<label class="col-md-1 control-label">地级市名称</label>
			<div class="col-md-2">
				<select class="form-control" rel-action="select" name="city" onchange="changeCounty(this);">
					<option value="">不限</option>
					{volist name="addr['city']" id="item"}
					{if isset($request.county) && $request.city == $item.code}
					<option value="{$item.code}" selected="selected">{$item.name}</option>
					{else /}
					<option value="{$item.code}">{$item.name}</option>
					{/if}
					{/volist}
				</select>
			</div>
			{/if}
			{if $request.type < 3}
			<label class="col-md-1 control-label">区县名称</label>
			<div class="col-md-2">
				<select class="form-control" rel-action="select" name="area">
					<option value="">不限</option>
					{if $request.type === 2 || empty($request.city) === false }
					{volist name="addr['county']" id="item"}
					{if isset($request.area) && $request.area == $item.code}
					<option value="{$item.code}" selected="selected">{$item.name}</option>
					{else /}
					<option value="{$item.code}">{$item.name}</option>
					{/if}
					{/volist}
					{/if}
				</select>
			</div>
			{/if}
			<label class="col-md-1 control-label">经纪人编号</label>
			<div class="col-md-2">
				<input type="text" class="form-control" name="tgnumber" value="{$request.tgnumber|default=''}" placeholder="请输入经纪人编号" autocomplete="off">
			</div>
			<label class="col-md-1 control-label">姓名</label>
			<div class="col-md-2">
				<input type="text" class="form-control" name="truename" value="{$request.truename|default=''}" placeholder="请输入姓名" autocomplete="off">
			</div>
			<label class="col-md-1 control-label">电话</label>
			<div class="col-md-2">
				<input type="text" class="form-control" name="telephone" value="{$request.telephone|default=''}" placeholder="请输入电话" autocomplete="off">
			</div>
		</div>
		<div class="form-group">
			<label class="col-md-1 control-label">状态</label>
			<div class="col-md-2">
				<select class="form-control" rel-action="select" name="status">
					<option value="">不限</option>
					{volist name="data.status" id="item"}
					{if array_key_empty($request, 'status') === "$key"}
					<option value="{$key}" selected="selected">{$item}</option>
					{else /}
					<option value="{$key}">{$item}</option>
					{/if}
					{/volist}
				</select>
			</div>
		</div>
	</div>
	<div class="box-footer">
		<div class="col-md-offset-1">
			<button type="submit" class="btn btn-default">查询</button>
			<a class="btn btn-default" href="{:url('page')}">重置</a>
		</div>
	</div>
	</form>
</div>
<div class="box box-primary">
	<div class="box-header with-border">
		<h3 class="box-title"></h3>
		<div class="box-tools">
			<a class="btn btn-default" href="#">
				今日新增经纪人：{$data.dayInfo}
			</a>
			<a class="btn btn-default" href="#">
				总人数：{$data.data->total()}
			</a>
		</div>
	</div>
	<div class="box-body table-responsive">
		<table class="table table-bordered table-striped table-hover">
			<tbody>
				{notempty name="data.data"}
				<tr>
					<th class="text-center">经纪人编号</th>
					<th class="text-center">姓名</th>
					<th class="text-center">电话</th>
					<th class="text-center">经纪人地址</th>
					<th class="text-center">团队数量</th>
					<th class="text-center">商家数量</th>
					<th class="text-center">状态</th>
					<th class="text-center">操作</th>
				</tr>
				{volist name='data.data' id='items'}
				<tr>
					<td class="text-center">{$items.tgnumber}</td>
					<td class="text-center">{$items.truename}</td>
					<td class="text-center">{$items.telephone}</td>
					<td class="text-center">{$items.address ?? '暂无'}</td>
					<td class="text-center">{$items.count ?? 0}</td>
					<td class="text-center">{$items.seller_count}</td>
					{if $items.status !== 0 }
					<td class="text-center">{$items.status_map}</td>
					{else /}
					<td class="text-center">
						<select style="min-width:80px;" rel-action="select" onchange="changeStatus(this, '{$items.id}')" name="change_status">
							<option value="0" selected>待审核</option>
							<option value="1">通过</option>
						</select>
					</td>
					{/if}
					<td class="text-center">
						<a href="{:url('detail',['id' => $items['id']])}">详情</a>
					</td>
				</tr>
				{/volist}
				{else /}
				<tr>
					<td>暂无符合条件记录</td>
				</tr>
				{/notempty}
			</tbody>
		</table>
	</div>
	{notempty name="data.data"}
	<div class="box-footer clearfix">
		{$data.data->render()|raw}
	</div>
	{/notempty}
</div>
{/block}